#!/bin/sh
##########################################################################
# This file is part of Hawkengine.
#
# Hawkengine is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option any later version.
#
# Hawkengine is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Hawkengine.  If not, see <http://www.gnu.org/licenses/>.
##########################################################################

NOW=`date -R`

DEBIAN_CONTROL=$DEBIAN_DIR/control
echo "Source: $DEBIAN_APP" > $DEBIAN_CONTROL
echo "Section: user/other" >> $DEBIAN_CONTROL
echo "Priority: optional" >> $DEBIAN_CONTROL
echo "Maintainer: $DEBIAN_AUTHOR <$DEBIAN_AUTHOR_EMAIL>" >> $DEBIAN_CONTROL
echo "Build-Depends: debhelper (>= 5), libqt4-dev" >> $DEBIAN_CONTROL
echo "Standards-Version: 3.7.3" >> $DEBIAN_CONTROL
echo "Homepage: $DEBIAN_WEBSITE" >> $DEBIAN_CONTROL
echo "" >> $DEBIAN_CONTROL
echo "Package: $DEBIAN_APP" >> $DEBIAN_CONTROL
echo "Architecture: any" >> $DEBIAN_CONTROL
echo "Version: $DEBIAN_VERSION" >> $DEBIAN_CONTROL
echo "Depends: \${shlibs:Depends}, \${misc:Depends}" >> $DEBIAN_CONTROL
echo "Description: $DEBIAN_DESCRIPTION" >> $DEBIAN_CONTROL
echo "XSBC-Maemo-Display-Name: $DEBIAN_APP_NAME" >> $DEBIAN_CONTROL
echo "XB-Maemo-Icon-26:" >> $DEBIAN_CONTROL
base64 $DEBIAN_DIR/${DEBIAN_APP}_26.png | sed 's/^/ /' >> $DEBIAN_CONTROL

DEBIAN_CHANGELOG=$DEBIAN_DIR/changelog
echo "$DEBIAN_APP ($DEBIAN_VERSION) unstable; urgency=low" > $DEBIAN_CHANGELOG
echo "" >> $DEBIAN_CHANGELOG
echo "  * Initial release" >> $DEBIAN_CHANGELOG
echo "" >> $DEBIAN_CHANGELOG
echo " -- $DEBIAN_MAINTAINER <$DEBIAN_AUTHOR_EMAIL>  $NOW" >> $DEBIAN_CHANGELOG

DEBIAN_AEGIS=$DEBIAN_DIR/$DEBIAN_APP.aegis
echo "<aegis>" > $DEBIAN_AEGIS
echo "   <request>" >> $DEBIAN_AEGIS
echo "      <credential name=\"UID:user\" />" >> $DEBIAN_AEGIS
echo "   </request>" >> $DEBIAN_AEGIS
echo "</aegis>" >> $DEBIAN_AEGIS


DEBIAN_RULES=$DEBIAN_DIR/rules
echo "#!/usr/bin/make -f" > $DEBIAN_RULES
echo "# -*- makefile -*-" >> $DEBIAN_RULES
echo "# Uncomment this to turn on verbose mode." >> $DEBIAN_RULES
echo "#export DH_VERBOSE=1" >> $DEBIAN_RULES
echo "configure: configure-stamp" >> $DEBIAN_RULES
echo "configure-stamp:" >> $DEBIAN_RULES
echo "	dh_testdir" >> $DEBIAN_RULES
echo "	# Add here commands to configure the package." >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "	touch configure-stamp" >> $DEBIAN_RULES
echo "	qmake -recursive" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "build: build-stamp" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "build-stamp: configure-stamp  " >> $DEBIAN_RULES
echo "	dh_testdir" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "	# Add here commands to compile the package." >> $DEBIAN_RULES
echo "	\$(MAKE)" >> $DEBIAN_RULES
echo "	#docbook-to-man debian/myprogram.sgml > myprogram.1" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "	touch \$@" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "clean: " >> $DEBIAN_RULES
echo "	dh_testdir" >> $DEBIAN_RULES
echo "	dh_testroot" >> $DEBIAN_RULES
echo "	rm -f build-stamp configure-stamp" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "	# Add here commands to clean up after the build process." >> $DEBIAN_RULES
echo "	-\$(MAKE) clean" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "	dh_clean " >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "install: build" >> $DEBIAN_RULES
echo "	dh_testdir" >> $DEBIAN_RULES
echo "	dh_testroot" >> $DEBIAN_RULES
echo "	dh_prep  " >> $DEBIAN_RULES
echo "	dh_installdirs" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "	# Add here commands to install the package into debian/myprogram." >> $DEBIAN_RULES
echo "	\$(MAKE) INSTALL_ROOT=\$(CURDIR)/debian/tmp install" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "# Build architecture-independent files here." >> $DEBIAN_RULES
echo "binary-indep: install" >> $DEBIAN_RULES
echo "# We have nothing to do by default." >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "# Build architecture-dependent files here." >> $DEBIAN_RULES
echo "binary-arch: install" >> $DEBIAN_RULES
echo "	dh_testdir" >> $DEBIAN_RULES
echo "	dh_testroot" >> $DEBIAN_RULES
echo "	dh_installchangelogs " >> $DEBIAN_RULES
echo "	dh_installdocs" >> $DEBIAN_RULES
echo "	dh_installexamples" >> $DEBIAN_RULES
echo "#	dh_install" >> $DEBIAN_RULES
echo "#	dh_installmenu" >> $DEBIAN_RULES
echo "#	dh_installdebconf" >> $DEBIAN_RULES
echo "#	dh_installlogrotate" >> $DEBIAN_RULES
echo "#	dh_installemacsen" >> $DEBIAN_RULES
echo "#	dh_installpam" >> $DEBIAN_RULES
echo "#	dh_installmime" >> $DEBIAN_RULES
echo "#	dh_python" >> $DEBIAN_RULES
echo "#	dh_installinit" >> $DEBIAN_RULES
echo "#	dh_installcron" >> $DEBIAN_RULES
echo "#	dh_installinfo" >> $DEBIAN_RULES
echo "	dh_installman" >> $DEBIAN_RULES
echo "	dh_link" >> $DEBIAN_RULES
echo "	dh_strip" >> $DEBIAN_RULES
echo "	dh_compress" >> $DEBIAN_RULES
echo "	dh_fixperms" >> $DEBIAN_RULES
echo "#	dh_perl" >> $DEBIAN_RULES
echo "#	dh_makeshlibs" >> $DEBIAN_RULES
echo "	dh_installdeb" >> $DEBIAN_RULES
echo "	dh_shlibdeps" >> $DEBIAN_RULES
echo "	dh_gencontrol" >> $DEBIAN_RULES
echo "	dh_md5sums" >> $DEBIAN_RULES
echo "	dh_builddeb" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "aegis-deb-add -control debian/$DEBIAN_APP/DEBIAN/control .. debian/$DEBIAN_APP.aegis=_aegis" >> $DEBIAN_RULES
echo "" >> $DEBIAN_RULES
echo "binary: binary-indep binary-arch" >> $DEBIAN_RULES
echo ".PHONY: build clean binary-indep binary-arch binary install configure" >> $DEBIAN_RULES
chmod a+x $DEBIAN_RULES

